﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>添加车间</title>
    <link href="~/libs/layui-v2.9.17/layui/css/layui.css" rel="stylesheet" />
    <script src="~/libs/layui-v2.9.17/layui/layui.js"></script>
    <script src="~/libs/jquery/jquery.js"></script>
</head>

<body>
    <form class="layui-form" action="" onsubmit="return false">
        <div class="layui-form-item">
            <label class="layui-form-label">车间编码</label>
            <div class="layui-input-block">
                <input type="text" name="WorkshopCode" id="WorkshopCode" required lay-verify="required" placeholder="请输入车间编码" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">车间名称</label>
            <div class="layui-input-block">
                <input type="text" name="WorkshopName" id="WorkshopName" required lay-verify="required" placeholder="请输入车间名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">面积</label>
            <div class="layui-input-block">
                <input type="text" name="Area" id="Area" required lay-verify="required" placeholder="请输入面积" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">负责人</label>
            <div class="layui-input-block">
                <input type="text" name="Charger" id="Charger" required lay-verify="required" placeholder="请输入负责人" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否启用</label>
            <div class="layui-input-block">
                <input type="radio" name="EnableFlag" value="是" title="是" checked>
                <input type="radio" name="EnableFlag" value="否" title="否">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea name="Remark" id="Remark" placeholder="请输入备注" class="layui-textarea"></textarea>
            </div>
        </div>
        <input type="hidden" name="Id" id="Id">
    </form>
    <script type="text/javascript">
        layui.use('form', function () {
            const form = layui.form;
            form.render();
            var id = window.location.search.substring(4);

            $.ajax({
                url: '/api/WorkShop/GetWorkShopById?id=' + id,
                type: 'get',
                data: $('#form').serialize(),
                success: function (res) {
                    console.log(res)
                    $("#Id").val(res.id)
                    $("#WorkshopCode").val(res.workshopCode)
                    $("#WorkshopName").val(res.workshopName)
                    $("#Area").val(res.area)
                    $("#Charger").val(res.charger)
                    $("#Remark").val(res.remark)
                    $("input[name='EnableFlag'][value='" + res.enableFlag + "']").prop('checked', true);
                }
            });
        })
    </script>
</body>
</html>
